// 1. 引入request
import request from '@/utils/request'


// 2. 使用枚举来存储接口
enum Api {
  // 获取spu列表数据
  getSpuListApi = '/admin/product',
  // 获取所有的品牌列表数据
  getAllTrademarkListApi = '/admin/product/baseTrademark/getTrademarkList',
  // 获取销售属性列表
  getBaseSaleAttrListApi = '/admin/product/baseSaleAttrList',
  // 添加spuInfo
  saveSpuInfoApi = '/admin/product/saveSpuInfo',
  // 更新spuInfo
  updateSpuInfoApi = '/admin/product/updateSpuInfo',
  // 删除spuInfo
  deleteSpuInfoApi = '/admin/product/deleteSpu',
  // 获取所有的spuInfo相关的图片
  getSpuImageListApi = '/admin/product/spuImageList',
  // 获取spuInfo相关的销售属性
  getSpuSaleAttrListApi = '/admin/product/spuSaleAttrList'

}


//  3. 根据三级导航id来获取spu列表数据
export const reqGetSpuListData = (page: number, limit: number, category3Id: number) => {
  return request.get(Api.getSpuListApi + `/${page}/${limit}?category3Id=${category3Id}`)
}

//  4. 获取所有的品牌列表数据
export const reqGetAllTrademarkList = () => {
  return request.get(Api.getAllTrademarkListApi)
}

  // 5. 获取销售属性列表数据
export const reqGetBaseSaleAttrList = () => {
  return request.get(Api.getBaseSaleAttrListApi)
}

// 添加spuInfo
export const reqSaveSpuInfo = (spuInfo) => {
  return request.post(Api.saveSpuInfoApi, spuInfo)
}

// 更新spuInfo
export const reqUpdateSpuInfo = (spuInfo) => {
  return request.post(Api.updateSpuInfoApi, spuInfo)
}

// 8. 删除spuInfo
export const reqDeleteSpuInfo = (spuId) => {
  return request.delete(Api.deleteSpuInfoApi + `/${spuId}`)
}
// 获取spuInfo下面的所有的图片
export const reqGetSpuImageList = (spuId) => {
  return request.get(Api.getSpuImageListApi + `/${spuId}`)
}
// 获取spuInfo下面的所有的销售属性及属性值
export const reqGetSpuSaleAttrList = (spuId) => {
  return request.get(Api.getSpuSaleAttrListApi + `/${spuId}`)
}